package com.kun.lagou.dao;

import com.kun.lagou.entity.UrlMap;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.repository.CrudRepository;

import javax.persistence.LockModeType;

/**
 * @author Administrator
 */
public interface UrlMapDao extends CrudRepository<UrlMap, Long> {
    /**
     * 加锁
     * select * from table where xxx for update;
     * @param longUrl
     * @return
     */
    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    UrlMap findFirstByLongUrl(String longUrl);
}
